#if UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || UNITY_WSA || UNITY_WEBGL
using Net.System;
using Net.Unity;
using System.Collections.Generic;
using UnityEngine;

namespace Net.UnityComponent
{
    public class PrefabCollectionComponent : MonoBehaviour, IPrefabCollection
    {
        public List<PrefabInfo2> prefabInfos = new();
        private MyDictionary<int, PrefabInfo2> prefabs;

        public bool GetPrefab(int prefabHash, out GameObject prefab)
        {
            if (prefabs == null)
            {
                prefabs = new MyDictionary<int, PrefabInfo2>();
                for (int i = 0; i < prefabInfos.Count; i++)
                    prefabs.Add(prefabInfos[i].prefabHash, prefabInfos[i]);
            }
            if (!prefabs.TryGetValue(prefabHash, out var prefabInfo))
            {
                prefab = null;
                return false;
            }
            prefab = prefabInfo.prefab;
            return true;
        }
    }
}
#endif